﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;

namespace TbDataSync
{
    public partial class Program
    {
        //旧tb请求器
        private static HttpClient old_client = new HttpClient() { BaseAddress = new Uri("http://192.168.110.42:9090") };//http://127.0.0.1:8082
        //新tb请求器
        private static HttpClient new_client = new HttpClient() { BaseAddress = new Uri("http://192.168.110.42:9090") };
        //旧tb鉴权信息
        static Identity fromIdentity = new Identity() { username = "tenant@thingsboard.org", password = "tenant" };
        //新tb鉴权信息
        static Identity targetIdentity = new Identity() { username = "tenant@thingsboard.org", password = "tenant" };
        //开始时间
        static long startTs = TimeFactory.GetUnixTimestamp(DateTime.Parse("2022-01-21"));
        //结束时间
        static long endTs = TimeFactory.GetUnixTimestampNow();
        //请求间隔,单位秒
        static int waitSeconds = 2;
        //是否启用随机设备名
        static bool ramdomDeviceName = false;
        //地址集合
        private static Dictionary<string, string> urls = new Dictionary<string, string>() {
            { "login","/api/auth/login"},
            { "device_list","/api/tenant/deviceInfos?pageSize=%rows%&page=%page%&sortProperty=createdTime&sortOrder=ASC&deviceProfileId=" },
            { "search_device","/api/tenant/devices?textSearch=%deviceName%&pageSize=10&page=0"},
            { "apply_device","/api/deviceProfileInfo/default" },
            { "add_device","/api/device"},
            { "attr_list","/api/plugins/telemetry/DEVICE/%deviceId%/values/attributes"},
            { "time_list","/api/plugins/telemetry/DEVICE/%deviceId%/keys/timeseries"},
            { "get_token","/api/device/%deviceId%/credentials"},
            { "post_attr","/api/v1/%token%/attributes"},
            { "post_timeseries","/api/v1/%token%/telemetry"},
            { "get_timeseries","/api/plugins/telemetry/DEVICE/%deviceId%/values/timeseries?limit=100&agg=NONE&orderBy=DESC&useStrictDataTypes=false&keys=%keys%&startTs=%startTs%&endTs=%endTs%"}
        };
        //失败设备记录文件
        static string failedDeviceFileName = "failed_devices.log";
        //失败设备计数
        static long failedFileNum = 0L;
    }
}
